// JavaScript Document

var x = null;
var y = null;
var w = 0;
var h = 0;
document.onmousemove = function shoHandle(event) {
	ev = event || window.event; 
	x = ev.clientX;
	y = ev.clientY;
	if(y<55&&select.offsetHeight<10){
		document.onmousemove = null;
		var s = setInterval(function(){
			h = h + 5;
			select.style.height = h +"px";		
			if(h==100){
				clearInterval(s);
				document.onmousemove = shoHandle;
				select.style.dispaly = "none";
			}
		},1);
	}
	else if(y>460){
		h = 0;
		select.style.height = 0 +"px";
	}
	if(x<2&&createSection.offsetWidth<10){
		document.onmousemove = null;
		var c = setInterval(function(){
			w = w + 10;
			createSection.style.width = w +"px";		
			if(w>=410){
				clearInterval(c);
				document.onmousemove = shoHandle;
				createSection.style.dispaly = "none";
			}
		},1);
	}
	else if(x>1000){
		w = 0;
		createSection.style.width = 0 +"px";
	}
}
function createWall(){
	var wallName = document.getElementById("wallName").value;
	var pictureSrc = document.getElementById("pictureSrc").value;
	var notes = document.getElementById("notes").value;
}
/*function searchWall(){
	var sName = document.getElementById("sName").value;
	var date = document.getElementById("control_date").value;
	if(sName&&date){
		alert("请确定搜索条件");
		return;
	}
	
}*/
function pictureGroup(){
	var myajax = getByAjax();
	myajax.init(null,"get",true);
	myajax.get("/networkforum/picture/get_groups.do",function(d){
//		var data = eval("("+d+")");
		var data = toJson(d);
		groups = data;
	});
	myajax = null;
	document.getElementById("pictureHandle").style.display = "";
}
var groups = [];
function showGroups(){
	var param={
		'targetId':"gn",
		'data':groups
	}
	var groupOption={
		'name':{
			'param':{
				'id':"groupName",
				'onmousedown':loadPictures
			},
			'bind':{
				'groupId':"groupId"
			}
		}
	}
	page.combo("groupList",param,groupOption);
	//page.view("ulInner",groups,groupOption);
}
function loadPictures(event){
	event = event||window.event;
	var target = event.target||event.srcElement;
	var groupId = target.groupId;
	
	var myajax = getByAjax();
	myajax.init(null,"get",true);
	myajax.get("/networkforum/picture/group_pictures.do?index=0&size=50&groupId="+groupId,function(d){
//		var data = eval("("+d+")");
		var data = toJson(d);
		page.view.clear("ulInner",false);
		page.view("ulInner",data,pictureOption);
	});
	myajax = null;
}
var pictureOption = {
	'pictureSrc':{
		'param':{
			'id':"picture"
		},
		'bind':{
			'pictureId':"pictureId",'onclick':pictureChoice
		}
	}	
}
function cancle(){
	document.getElementById("pictureHandle").style.display = "none";
}
function pictureChoice(event){
	event = event || window.event;
	var target = event.target||event.srcElement;
	var ok = document.getElementById("OK");
	ok.pictureId = target.pictureId;
	if(ok.img){
		ok.img.style.border = "none";
	}
	ok.img = target;
	
	with(target.style){
		border = "1px solid red";
	}
	
}
function pictureOk(event){
	var ok = document.getElementById("OK");
	if(!ok.img){
		alert("请选择图片!");
		return;
	}
	cancle();
	//ok.pictureId = target.pictureId;
	var picShow = document.getElementById("pictureSrc");
	//picShow.appendChild(ok.img);
	picShow.value = ok.img.src;
}
function picker(event){
	event = event||window.event;
	var target = event.target||event.srcElement;
	var picker = document.getElementById("picker");
	with(picker.style){
		left = target.offsetLeft + "px";
		top = target.offsetTop -23 + "px";
		display = "";
	}
	f.linkTo(target);
}
function rPicker(event,option){
	event = event||window.event;
	var target = event.target||event.srcElement;
	var picker = document.getElementById("picker");
	picker.style.display = "none";
	target.value = target.style.backgroundColor;
	
	var frame = document.getElementById("wallInnerFish");
	if(option == "frame"){
		frame.style.boxShadow ="0px 2px 15px "+target.value;
	}
	else{
		frame.children[1].style.boxShadow ="0px 2px 15px "+target.value;
	}
}